package com.hs.controller;

import com.hs.entity.CompanyInfo;
import com.hs.service.CompanyInfoService;
import com.hs.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("companyinfo")
public class CompanyInfoController {
    @Autowired
    private CompanyInfoService companyInfoService;
    @PostMapping
    public R addCompanyInfo(@RequestBody CompanyInfo companyInfo) {
        int i = companyInfoService.addCompanyInfo(companyInfo);
        if (i > 0) {
            return R.ok();
        }
        return R.fail("失败");
    }
    @PutMapping
    public R updateCompanyInfo(@RequestBody CompanyInfo companyInfo) {
        int i = companyInfoService.updateCompanyInfo(companyInfo);
        if (i > 0) {
            return R.ok();
        }
        return R.fail("失败");
    }
    @DeleteMapping("{id}")
    public R deleteCompanyInfo(@PathVariable("id") int id) {
        int i = companyInfoService.deleteCompanyInfo(id);
        if (i > 0) {
            return R.ok();
        }
        return R.fail("失败");
    }
    @GetMapping("{id}")
    public R getCompanyInfo(@PathVariable("id") int id) {
        CompanyInfo companyInfo = companyInfoService.getCompanyInfo(id);
        return R.ok(companyInfo);
    }
}
